<template>
  <el-form :model="formData" label-width="120px" label-position="left">
    <el-form-item label="姓名" prop="name" required>
      <el-input v-model="formData.name" placeholder="请输入您的姓名" />
    </el-form-item>
    
    <el-form-item label="性别" prop="gender" required>
      <el-radio-group v-model="formData.gender">
        <el-radio value="male">男</el-radio>
        <el-radio value="female">女</el-radio>
      </el-radio-group>
    </el-form-item>
    
    <el-form-item label="手机号" prop="phone" required>
      <el-input v-model="formData.phone" placeholder="请输入您的手机号" />
    </el-form-item>
    
    <el-form-item label="邮箱" prop="email" required>
      <el-input v-model="formData.email" placeholder="请输入您的邮箱" />
    </el-form-item>
    
    <el-form-item label="当前身份" prop="status" required>
      <el-select v-model="formData.status" placeholder="请选择您的身份">
        <el-option label="在校学生" value="student" />
        <el-option label="在职人员" value="employee" />
        <el-option label="待业" value="unemployed" />
      </el-select>
    </el-form-item>
  </el-form>
</template>

<script setup>
import { reactive, watchEffect, onMounted, onBeforeMount } from 'vue'

const props = defineProps({
  initialData: {
    type: Object,
    default: () => ({})
  }
})
const formData = reactive({
  name: '',
  gender: '',
  phone: '',
  email: '',
  status: ''
})

// 初始化表单数据
onMounted(() => {
  // console.log("basic表单获取数据：",props.initialData);
  Object.assign(formData, props.initialData)
})

const getFormData = () => {
  // console.log("basic表单被请求发送数据");
  return Promise.resolve(formData)
}

defineExpose({
  getFormData
})


</script>
